'use strict';
angular.module('nec-admin.user')
    .directive('pwCheck', [function () {
        return {
            restrict: 'A',
            require: 'ngModel',
            link: function (scope, elem, attr, ctrl) {
                var firstPassword = '#' + attr.pwCheck;
                elem.add(firstPassword).on('keyup', function () {
                    scope.$apply(function () {
                        var v = typeof elem.val() === 'undefined'|| elem.val().length === 0 || elem.val() === $(firstPassword).val();
                        ctrl.$setValidity('pwCheck', v);
                    });
                });
            }
        };
    }]);
